def signal(*args):
    df = args[0]
    n = args[1]
    factor_name = args[2]

    df['bbi'] = (df['close'].rolling(n, min_periods=1).mean() +
                 df['close'].rolling(2 * n, min_periods=1).mean() +
                 df['close'].rolling(4 * n, min_periods=1).mean() +
                 df['close'].rolling(8 * n, min_periods=1).mean()) / 4
    df['bbi_bias'] = df['close'] / df['bbi']

    df['振幅'] = (df['high'] - df['low']) / df['open']
    df['factor'] = (df['quote_volume'] / df['振幅']) * (df['trade_num'] / df['振幅'])

    df[factor_name] = df['factor'].rolling(n, min_periods=1).mean() * df['bbi_bias']

    return df
